package com.crm.system.mapper;

import com.crm.entity.SysDepartment;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface SysDepartmentMapper {
    @Insert("INSERT INTO sys_department (id,dep_name, disabled) VALUES(#{id},#{depName}, 0)")
    int Insert(SysDepartment sysDepartment);

    @Delete("UPDATE sys_department SET disabled=1 WHERE id=#{id}")
    int remove(String id);

    @Select("SELECT * FROM sys_department where disabled=0")
    List<SysDepartment> list();

    @Select("select * from sys_department where id=#{id}")
    SysDepartment get(String id);

    @Update("update sys_department set dep_name=#{depName}, "+
            "parent_id=#{parentId} " +
            "where id=#{id}")
    int update(SysDepartment department);

    @Select("select sys_user.true_name  from sys_user right join sys_department on sys_user.dep_id =sys_department.id  where sys_user.dep_id =#{depId} ")
    List<String> idInfo(String depId);


}
